package org.example.feign;

import org.example.entity.User;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "product", configuration = LoadBalancerClientConfiguration.class)
public interface ProductClient {

    @GetMapping("/product/get_info")
    String getInfo(@RequestParam("id") Long id);

    @GetMapping("/product/{name}")
    String getName(@PathVariable("name") String name);

    //注意：openfeign 中对象传参只能使用 POST，并且也符合使用习惯
    //GET 请求传对象会报错: Method Not Allowed
    @PostMapping("/product/get_user")
    String getUser(@RequestBody User user);

    @GetMapping("/product/get_arr")
    String getArr(@RequestParam("arr") String[] arr);

    @PostMapping("/product/get_user_list")
    String getUserList(@RequestBody User user);

    @GetMapping("/product/get_data")
    String getData();

}
